package com.zx.znav.interceptor;

import com.zx.znav.constant.Constants;
import com.zx.znav.controller.vo.UserVO;
import com.zx.znav.utils.UserHolder;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 挚爱之夕
 * @version 1.0
 * @implSpec 后台登录拦截器
 * @since 2023-06-21 15:19
 */
public class AdminLoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response,
                             Object handler) throws Exception {
        if (request.getSession().getAttribute(Constants.SESSION_USER_KEY) == null) {
            response.sendRedirect("/admin");
            return false;
        }
        return true;
    }
}
